package vip.xiaonuo.biz.modular.lancerGoodsBox.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.dromara.easyes.core.biz.EsPageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.lancerCoupon.entity.BizCoupon;
import vip.xiaonuo.biz.modular.lancerGoods.service.BizGoodsService;
import vip.xiaonuo.biz.modular.lancerGoodsBox.service.BizGoodsBoxService;
import vip.xiaonuo.biz.modular.pojo.domain.BizGoods;
import vip.xiaonuo.biz.modular.pojo.domain.BizGoodsBox;
import vip.xiaonuo.biz.modular.pojo.dto.common.CommonDetailDTO;
import vip.xiaonuo.biz.modular.pojo.dto.page.ClientGoodsBoxPageDTO;
import vip.xiaonuo.biz.modular.pojo.dto.page.GoodsBoxPageDTO;
import vip.xiaonuo.biz.modular.pojo.dto.page.GoodsPageDTO;
import vip.xiaonuo.biz.modular.pojo.vo.KV;
import vip.xiaonuo.biz.modular.pojo.vo.LV;
import vip.xiaonuo.common.pojo.CommonResult;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "消费者商品盒子管理")
@ApiSupport(author = "LANCER_TEAM", order = 1)
@RestController
@RequestMapping
@Validated
public class ClientGoodsBoxController {
    @Autowired
    private BizGoodsService GoodsService;
    @Autowired
    private BizGoodsBoxService bizGoodsBoxService;

//    @ApiOperationSupport(order = 1)
//    @ApiOperation("镇店之宝")
//    @GetMapping("/biz/client/goodsBox/TreasureOfZhendian")
//    public CommonResult<Page<BizGoodsBox>> TreasureOfZhendian(@Valid ClientGoodsBoxPageDTO dto) {
//        Page<BizGoodsBox> res = bizGoodsBoxService.TreasureOfZhendian(dto);
//        return CommonResult.data(res);
//    }

    @ApiOperationSupport(order = 1)
    @ApiOperation("镇店之宝ES")
    @GetMapping("/biz/client/goodsBox/TreasureOfZhendian")
    public CommonResult<EsPageInfo<BizGoodsBox>> TreasureOfZhendian(@Valid ClientGoodsBoxPageDTO dto) {
        EsPageInfo<BizGoodsBox> res = bizGoodsBoxService.TreasureOfZhendianByES(dto);
        return CommonResult.data(res);
    }

    @ApiOperationSupport(order = 1)
    @ApiOperation("新品发布")
    @GetMapping("/biz/client/goodsBox/NewGoods")
    public CommonResult<Page<BizGoodsBox>> NewGoods(@Valid ClientGoodsBoxPageDTO dto) {
        Page<BizGoodsBox> res = bizGoodsBoxService.NewGoods(dto);
        return CommonResult.data(res);
    }

    @ApiOperationSupport(order = 1)
    @ApiOperation("秒杀商品")
    @GetMapping("/biz/client/goodsBox/GoodsKill")
    public CommonResult<Page<BizGoodsBox>> GoodsKill(@Valid ClientGoodsBoxPageDTO dto) {
        Page<BizGoodsBox> res = bizGoodsBoxService.GoodsKill(dto);
        return CommonResult.data(res);
    }

    @ApiOperationSupport(order = 1)
    @ApiOperation("获取当前用户在当前盒子的优惠券")
    @GetMapping("/biz/client/goodsBox/getCouponByBoxId/{id}")
    public CommonResult<List<BizCoupon>> getCouponByBoxId(@PathVariable("id") String id) {
        List<BizCoupon> list = bizGoodsBoxService.getCouponListByBoxId(id);
        return CommonResult.data(list);
    }
    @ApiOperationSupport(order = 7)
    @ApiOperation("词条搜索")
    @GetMapping("/biz/client/goodsBox/handleSearch/{searchVal}")
    public CommonResult<List<LV>> handleSearch(@PathVariable("searchVal") String searchVal) {
        List<LV> list = bizGoodsBoxService.handleSearch(searchVal);
        return CommonResult.data(list);
    }
//    @ApiOperationSupport(order = 1)
//    @ApiOperation("商品盒子搜索")
//    @GetMapping("/search")
//    public CommonResult<Page<BizGoodsBox>> search(@Valid GoodsBoxPageDTO dto) {
//        Page<BizGoodsBox> res = bizGoodsBoxService.pageClient(dto);
//        return CommonResult.data(res);
//    }
//    @ApiOperationSupport(order = 2)
//    @ApiOperation("商品盒子详情查询")
//    @GetMapping("/detail")
//    public CommonResult<BizGoodsBox> detail(@Valid CommonDetailDTO dto) {
//        BizGoodsBox res = GoodsBoxService.detail(dto);
//        return CommonResult.data(res);
//    }
}
